package com.autumn.sms.service.vo;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 发送模板
 * 
 * @author 老码农
 *
 *         2018-01-12 13:07:20
 */
public class SendTemplateValue implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8412256840022395610L;

	private String serviceId;
	private String servideName;
	private String serviceKey;
	/**
	 * Key 模板代码
	 */
	private Map<String, StandardTemplateValue> templates;

	public SendTemplateValue() {
		this.setTemplates(new HashMap<>());
	}

	public String getServiceId() {
		return serviceId;
	}

	public void setServiceId(String serviceId) {
		this.serviceId = serviceId;
	}

	public String getServideName() {
		return servideName;
	}

	public void setServideName(String servideName) {
		this.servideName = servideName;
	}

	public String getServiceKey() {
		return serviceKey;
	}

	public void setServiceKey(String serviceKey) {
		this.serviceKey = serviceKey;
	}

	public Map<String, StandardTemplateValue> getTemplates() {
		return templates;
	}

	public void setTemplates(Map<String, StandardTemplateValue> templates) {
		this.templates = templates;
	}

	/**
	 * 查找验证码模板
	 * 
	 * @param verificationCodeType
	 *            验证码类型
	 * @return
	 *
	 */
	public StandardTemplateValue findVerificationCodeTemplate(int verificationCodeType) {
		Map<String, StandardTemplateValue> ts = this.getTemplates();
		if (ts == null || ts.size() == 0) {
			return null;
		}
		for (StandardTemplateValue item : ts.values()) {
			if (item != null && item.getIsVerificationCode()
					&& item.getVerificationCodeType().equals(verificationCodeType)) {
				return item;
			}
		}
		return null;
	}

}
